const colorAdjust_frag_multisampled = /*wgsl*/ `
struct Input {  
    @location(0) uv : vec2<f32>,
};
struct Output {
    @location(0) color:vec4<f32>,
};
fn combieSample(Texture:texture_multisampled_2d<f32>,uv:vec2<u32>)->vec4<f32>{
    var sampler1= textureLoad(Texture,uv,0);
    var sampler2= textureLoad(Texture,uv,1);
    var sampler3= textureLoad(Texture,uv,2);
    var sampler4= textureLoad(Texture,uv,3);
    var average=(sampler1+sampler2+sampler3+sampler4)/4;
    return average;
 }
 fn getUInt(uv:vec2<f32>)->vec2<u32>{
    return vec2<u32>(u32(uv.x),u32(uv.y));
}
@group(0) @binding(0) var Sampler: sampler;
@group(0) @binding(1) var Texture: texture_multisampled_2d<f32>;
@group(0) @binding(2) var <uniform> brightness : f32;
@group(0) @binding(3) var <uniform> saturation : f32;
@group(0) @binding(4) var <uniform> contrast : f32;
@fragment
fn main(input:Input) -> Output {
    var output:Output;
    var colorVec4=combieSample(Texture,getUInt(input.uv));
    var color=colorVec4.rgb;
    // 亮度
    color=color * brightness;
    // 饱和度
    var luminance=dot(color, vec3(0.2125, 0.7154, 0.0721));
    var luminanceColor = vec3(luminance, luminance, luminance);
    color = mix(luminanceColor, color, saturation);
    // 对比度
    var grayColor = vec3(1.0, 1.0, 1.0);
    color = mix(grayColor, color, contrast);
    output.color=vec4(color,colorVec4.a) ;
    return output;
}
`;
const colorAdjust_frag = /*wgsl*/ `
struct Input {  
    @location(0) uv : vec2<f32>,
};
struct Output {
    @location(0) color:vec4<f32>,
};

@group(0) @binding(0) var Sampler: sampler;
@group(0) @binding(1) var Texture: texture_2d<f32>;
@group(0) @binding(2) var <uniform> brightness : f32;
@group(0) @binding(3) var <uniform> saturation : f32;
@group(0) @binding(4) var <uniform> contrast : f32;
@fragment
fn main(input:Input) -> Output {
    var output:Output;
    var colorVec4=textureSample(Texture, Sampler,input.uv);
    var color=colorVec4.rgb;
    // 亮度
    color=color * brightness;
    // 饱和度
    var luminance=dot(color, vec3(0.2125, 0.7154, 0.0721));
    var luminanceColor = vec3(luminance, luminance, luminance);
    color = mix(luminanceColor, color, saturation);
    // 对比度
    var grayColor = vec3(1.0, 1.0, 1.0);
    color = mix(grayColor, color, contrast);
    output.color=vec4(color,colorVec4.a) ;
    return output;
}
`;
export { colorAdjust_frag, colorAdjust_frag_multisampled };
